import store from '@/store'

/**
 * 检测是否存在某个菜单栏
 * @param {Array} value
 * @returns {Boolean}
 * @example see @/views/permission/directive.vue
 */
export default function checkMenu(value) {
  if (value && value instanceof Array && value.length > 0) {
    const menus = store.getters && store.getters.menus
    const menuParams = value

    return menus.some(menu => {
      return menuParams.includes(menu)
    })
  } else {
    console.error(`need menus! Like v-menus="['admin','editor']"`)
    return false
  }
}
